﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Windows.Markup;

namespace ViewMaker.Core.Tests
{
    public static class TestHelper
    {
        public static XamlNode CreateTestParent()
        {
            var doc = new XmlDocument();
            doc.LoadXml(
@"<ContentControl xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
     xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
     xmlns:system=""clr-namespace:System;assembly=mscorlib"">
    <ContentControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source=""/ViewMaker.Core;component/wpf/wpfgenericresource.xaml""/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </ContentControl.Resources> 
</ContentControl>");

            return new XamlNode(doc.FirstChild);
        }

        public static T GetFrameworkElement<T>(string xaml)
        {
            return (T)XamlReader.Parse(xaml);
        }

        public static T GetFrameworkElement<T>(XamlNode xaml)
        {
            return (T)XamlReader.Parse(xaml.Node.OuterXml);
        }

        public static string GetXamlCode(XamlNode xaml)
        {
            return xaml.Node.OuterXml;
        }

    }
}
